﻿using Singer.Shared.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Singer.Middleware.FreeSql
{
    public interface IBaseRepository<TEntity> : global::FreeSql.IBaseRepository<TEntity>
        where TEntity : class, IEntity
    {
        bool Any(Expression<Func<TEntity, bool>>? exp);

        Task<bool> AnyAsync(Expression<Func<TEntity, bool>>? exp);
        /// <summary>
        /// 获取单条数据，返回实体
        /// </summary>
        TEntity? Get(Expression<Func<TEntity, bool>>? exp);
        /// <summary>
        /// 获取单条数据，返回实体
        /// </summary>
        Task<TEntity?> GetAsync(Expression<Func<TEntity, bool>>? exp);
        /// <summary>
        /// 获取单条数据，返回Dto
        /// </summary>
        TDto? Get<TDto>(Expression<Func<TEntity, bool>>? exp) where TDto : class;
        /// <summary>
        /// 获取单条数据，返回Dto
        /// </summary>
        Task<TDto?> GetAsync<TDto>(Expression<Func<TEntity, bool>>? exp) where TDto : class;
    }
}
